/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package cn.edu.just.secondwebapp.serviceimpl;

import cn.edu.just.secondwebapp.dao.PersonDao;
import cn.edu.just.secondwebapp.entity.Person;
import cn.edu.just.secondwebapp.service.PersonService;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author JUST
 */
public class PersonServiceImpl implements PersonService{
    
    PersonDao personDao;

    public PersonServiceImpl(PersonDao personDao) {
        this.personDao = personDao;
    }
    
    

    @Override
    public boolean addPerson(Person p) {
        return personDao.doCreate(p);
    }

    @Override
    public boolean updatePerson(Person p) {
        return personDao.doUpdate(p);
    }

    @Override
    public List<Person> findAll(String fuzzyKey) {
        try {
            return personDao.findAll(fuzzyKey);
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return new ArrayList<>();
    }

    @Override
    public boolean removePerson(int id) {
        return personDao.doRemove(id);
    }
    
}
